/*
 * DbStudentAddress.h
 *
 *  Created on: 24 Apr 2010
 *      Author: Vastsor
 */

#ifndef STUDENTADDRESSDB_H_
#define STUDENTADDRESSDB_H_

#include "IStudentAddressDb.h"

#include <string>

using namespace std;

class StudentAddressDb:public IStudentAddressDb {
public:
	StudentAddressDb();
	StudentAddressDb(const string *dbName, const string *user, const string *passwd);
	virtual ~StudentAddressDb();
	/**
	 *Get maximum value of StudentAddresses.id plus one
	 *if StudentAddresses is empty returns '1'
	 * @return string *
	 */
	virtual string *getLastId()const;
	/**
	 * Inserts a new row in table StudentAddresses
	 * @param id , the value of StudentAddresses.id which insert
	 * @return boolean
	 */
	virtual bool saveId(const string *id) const ;

	/**
	 * Set/update the fk StudentA_id by aem
	 * @param aem, the value of aem
	 * @param id, the value of id
	 * @return boolean
	 */
	virtual bool saveStudentAddress(const string *aem,const string *id) const;
	/**
	 * Updates/Sets the column StudentAddresses.town
	 * @param id the value of StudentAddresses.id which row is update
	 * @param town the new value of StudentAddresses.town
	 * @return boolean
	 */
	virtual bool saveTown(const string *id, const string *town) const ;
	/**
	 * Updates/Sets the column StudentAddresses.name
	 * @param id the value of StudentAddresses.id which row is update
	 * @param streetName the new value of StudentAddresses.name
	 * @return boolean
	 */
	virtual bool saveStreetName(const string *id, const string *streetName) const ;
	/**
	 * Updates/Sets the column StudentAddresses.number
	 * @param id the value of StudentAddresses.id which row is update
	 * @param streetNumber the new value of StudentAddresses.number
	 * @return boolean
	 */
	virtual bool saveStreetNumber(const string *id, const string *streetNumber) const;
	/**
	 *Search for address by name,number and town
	 * @param streetName
	 * @param streetNumber
	 * @param town
	 * @return string * if Not null return that address id
	 */
	virtual string *getIdByAddress(const string *streetName, const string *streetNumber, const string *town) const;
	/**
	 * Get from StudentAddresses the column town by Student's aem
	 * @param aem Student's aem
	 * @return string *
	 */
	virtual string *getTown(const string *aem) const;
	/**
	 * Get from StudentAddresses the column name by Student's aem
	 * @param aem Student's aem
	 * @return string *
	 */
	virtual string *getStreetName(const string *aem) const;
	/**
	 * Get from StudentAddresses the column number by Student's aem
	 * @param aem Student's aem
	 * @return string *
	 */
	virtual string *getStreetNumber(const string *aem) const;
protected:
	/**
	 * Check if StudentAddresses is empty
	 * @return boolean true if table is empty or boolean false if table is not empty
	 */
	bool isEmpty() const;
};

#endif /* STUDENTADDRESSDB_H_ */
